package writer;

import java.io.BufferedWriter;
import java.io.FileWriter;
import java.io.IOException;

/**
 * @author 培培
 * @condition 努力学习中
 */
public class BufferedWriter_ {
    public static void main(String[] args) throws IOException {

        String filePath = "d:\\ok.txt";

        //创建 BufferedWriter
        BufferedWriter bufferedWriter = new BufferedWriter(new FileWriter(filePath,true));//带true，表示追加

        bufferedWriter.write("hello,继续努力");
        bufferedWriter.newLine();//插入一个和系统相关的换行符
        bufferedWriter.write("hello,继续努力");
        bufferedWriter.newLine();//插入一个和系统相关的换行符
        bufferedWriter.write("hello,继续努力");

        //关闭外层流即可，传入的 new FileWriter(filePath),会在底层关闭
        bufferedWriter.close();


    }
}
